package utils

import (
	"fmt"

	"golang.org/x/crypto/bcrypt"
)

// 密码加密
func EncryptPassword(password string) (string, error) {
	hash, err := bcrypt.GenerateFromPassword([]byte(password), 1)
	if err != nil {
		return "", err
	}
	fmt.Println(string(hash))
	return string(hash), nil
}

// 密码比对
func DecryptionPassword(loginPassword string, password string) error {
	err := bcrypt.CompareHashAndPassword([]byte(password), []byte(loginPassword))
	return err
}
